package campus.service.impl;

import campus.mapper.AccountMapper;
import campus.model.Account;
import campus.model.AccountExample;
import campus.service.AccountService;
import campus.util.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Properties;

/**
 * @author VULCAN
 * @create 2020-05-08 0:14
 * @desc 账套实现
 **/
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;
    @Override
    public List<Account> selectByExample(AccountExample example) {
        return accountMapper.selectByExample(null);
    }

    @Override
    public int insert(Account record) {
        record.setZtCdate(new Date());
        record.setZtCreadate(new Date());
        return accountMapper.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer ztId) {
        return accountMapper.deleteByPrimaryKey(ztId);
    }

    @Override
    public int updateByPrimaryKeySelective(Account record) {
        record.setZtCdate(new Date());
        return accountMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public PageResult findByAllPageSize(Account account, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Account> findlog = (Page<Account>) accountMapper.findByAllPageSize(account);
        return new PageResult(findlog.getTotal(),findlog.getResult());
    }

    @Override
    public Account findByPrimaryKey(Integer ztId) {
        return accountMapper.findByPrimaryKey(ztId);
    }
}
